class Solution {
public:
    int findPermutationDifference(string s, string t) {
        unordered_map<char, int> char2index;
        for (int i = 0; i < s.length(); ++i) {
            char2index[s[i]] = i;
        }
        int sum = 0;
        for (int i = 0; i < t.length(); ++i) {
            sum += abs(i - char2index[t[i]]);
        }
        return sum;
    }
};
